<include file="Public/min-header"/>
<div class="wrapper">
  <include file="Public/breadcrumb"/>
    <section class="content"> 
        <!-- Main content -->
		<style type="text/css">
			.autopush{background: #eee;border:1px solid #ccc;padding:0;width:350px;display:none;}
			.autopush li{cursor: pointer;list-style:none;border-bottom: 1px dashed #ccc;padding:5px;}
		</style>
        <div class="container-fluid">
            <div class="pull-right"> 
				<button class="btn btn-info" style="background: #68adbf;" type="button" onclick="location.href='/index.php/seller/Order/tuihuo_list'">
				    <i class="glyphicon glyphicon-th-list"></i>
				  		 返回列表
				</button>
                <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-list"></i>退货订单信息</h3>
                </div>
                <div class="panel-body">
                    <!--表单数据-->
                    <form method="post" action="/index.php?m=seller&c=Order&a=tuihuo_edit_order&id={:I('id')}" id="order-add">
                        <div class="tab-pane">
                            <table class="table table-bordered">
                                <tbody>
                                <tr>
                                    <td>收货人/店铺:</td>
                                    <td>
                                    <div class="form-group ">
	                                    <div class="col-xs-2">
	                                        {$order.nickname}
											<input type="hidden" name="user_id" id="user_id" value="{$order.user_id}" />
											<ul id="users" class="autopush"></ul>
                                        </div>  
                                        <div class="col-xs-2">
										    <span id="err_consignee" style="color:#F00; display:none;">收货人名字或店铺不能为空</span>
                                        </div> 
                                    </div>    
                                    </td>
                                </tr>
								<tr>
								    <td>商家店铺:</td>
								    <td>
								    <div class="form-group ">
								        <div class="col-xs-2">
								            {$order.store_name}
											<input type="hidden" name="store_id" id="store_id" value="{$order.store_id}" />
											<ul id="stores" class="autopush"></ul>
								        </div>  
								        <div class="col-xs-2">
										    <span id="err_store_name" style="color:#F00; display:none;">商铺名不能为空</span>
								        </div> 
								    </div>    
								    </td>
								</tr> 
                                <tr>
                                    <td>商品列表:</td>
                                    <td> 
                                       <div class="form-group">
                                       		<div class="col-xs-10">
                                       		<table class="table table-bordered">
                                       			<thead>
                                       			<tr>
									                <td class="text-left">商品名称</td> 
									                <td class="text-left">价格</td>								                										<td class="text-left">平台扣点</td>
									                <td class="text-left">数量</td>
									                <td class="text-left">买家理由（买家可见）</td>
									            </tr>
									            </thead> 
									            <tbody>
									            	<tr>
									                <td class="text-left">{$order.goods_name}</td>            
									               
									                <td class="text-left">{$order.member_goods_price}</td>
													<td class="text-left">{$order['points']}</td>
									                <td class="text-left">
									                {$order.goods_num}</td>
													<td class="text-left">
														{$order.reason}
													</td>

									           		</tr>
									           </tbody>
                                       		</table>
                                       	   </div>
                                       </div>                                              
                                    </td>
                                </tr>                              
                                <tr>
                                    <td>订单号/备注（商家可见）:</td>
                                    <td>
                                    <div class="form-group ">
	                                    <div class="col-xs-4">
										{$order.remark|htmlspecialchars_decode}
                                        </div>
										<div class="col-xs-2">
										    <span id="err_remark" style="color:#F00; display:none;">单号/备注不能为空</span>
										</div> 
                                    </div>    
                                    </td>
                                </tr>                                  
                                
                                </tbody>
                                </table>
                        </div>
                        <input type="hidden" name="id" value="{$order.id}">
                    </form> 
                </div>
            </div>
        </div> 
    </section>
</div>
<script>
   /* 用户订单区域选择 */
$(document).ready(function(){
	$('#province').val({$order.province});
	$('#city').val({$order.city});
	$('#district').val({$order.district});
	$('#shipping_id').val({$order.shipping_id});

  $(document).on('click','.autopush li',function(){
	  var myrel=$(this).attr('rel');
	  //var obj=$(this).parent().parent();
	  var myid=$(this).parent().attr('id');
	  var mytext=$(this).text();
	  if(myid=="users"){
		  $('#consignee').val(mytext);
		  $('#user_id').val(myrel);
	  }else if(myid=="stores"){
		  $('#store_name').val(mytext);
		  $('#store_id').val(myrel);
	  }
	  $(this).parent().hide();
  });
 
});

function autopush(e,action){
	var key=$(e).val();
	var obj=$(e).parent();
	obj.find('.autopush').show();
	$.post('/index.php?m=admin&c=Order&a=tuihuo_keys',{key:key,action:action},function(data){
		if(action=='user'){
			obj.find('#users').html(data);
		}else{
			obj.find('#stores').html(data);
		}
		
	})
}

// 选择商品
function selectGoods(){
	var store_id=$("#store_id").val();
	if(store_id==''){
		layer.msg('请选择退货的商家！', {icon: 5});return false;
	}
    var url = "/index.php/Admin/Order/search_goodss/store_id/"+store_id;
    layer.open({
        type: 2,
        title: '选择退货商品',
        shadeClose: true,
        shade: 0.8,
        area: ['60%', '60%'],
        content: url, 
    });
}

// 选择商品返回
function call_back(table_html)
{
	$('#goods_td').append('<table class="table table-bordered">'+table_html+'</table>');
	//过滤选择重复商品
	$('input[name*="spec"]').each(function(i,o){
		if($(o).val()){
			var name='goods_id['+$(o).attr('rel')+']['+$(o).val()+'][goods_num]';
			$('input[name="'+name+'"]').parent().parent().remove();
		}
	});
	layer.closeAll('iframe');
}

function checkSubmit()
{							
	$("span[id^='err_']").each(function(){
		$(this).hide();
	});
   ($.trim($('#consignee').val()) == '') && $('#err_consignee').show();
   ($.trim($('#store_name').val()) == '') && $('#err_store_name').show();
   ($.trim($('#remark').val()) == '') && $('#err_remark').show();
   // if(($("input[name^='goods_id']").length ==0) && ($("input[name^='old_goods']").length == 0)){
	  //  layer.alert('订单中至少要有一个商品', {icon: 2});  // alert('少年,订单中至少要有一个商品');
	  //  return false;
   // }												   
   if($("span[id^='err_']:visible").length > 0 ) 
      return false;							  
   $('#order-add').submit();	  
}
</script>
</body>
</html>